﻿using System;
using System.Collections.Generic;
using FNN.SourcePoints;
using System.Globalization;

namespace FNN.Factories.SourcePoints
{
    public class DateSourcePointFactory : SourcePointFactory
    {
        public override SourcePoint CreatePoint(string id)
        {
            string dateFormat;
            CultureInfo dateFormatProvider = CultureInfo.CreateSpecificCulture("ru-RU");
            if (id.Contains(" "))
            {
                dateFormat = "dd.MM.yyyy HH:mm:ss";
            }
            else
            {
                dateFormat = "dd.MM.yyyy";
            }

            return new DateSourcePoint
            {
                Coordinates = new Dictionary<string, double>(),
                PointDate = DateTime.ParseExact(id, dateFormat, dateFormatProvider)
            };
        }
    }
}
